package com.huobao.shangjia_version.activitys;

import java.util.Map;

import org.xutils.view.annotation.ViewInject;

import com.huobao.yunying.base.HuobaoBaseActivity;
import com.huobao.yunying.entity.StoreBaseSetting;
import com.huobao.yunying.https.Http;
import com.huobao.yunying.https.HttpListener;
import com.huobao.yunying.https.HttpUtil;
import com.huobao.zhangying.R;

import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

public class Act_Store_Seting extends HuobaoBaseActivity {

	private EditText edt_store_name;
	private EditText edt_tel;
	private EditText edt_qq;
	private EditText edt_wangwang;
	private EditText edt_baoyou_jine;
	private EditText edt_baoyou_shuliang;
	@ViewInject(R.id.edt_baoyou_content)
	private EditText edt_baoyou_content;

	private StoreBaseSetting baseSetting;

	@Override
	protected int getContentView() {
		// TODO Auto-generated method stub
		return R.layout.layout_store_setting;
	}

	@Override
	protected String getTitleText() {
		// TODO Auto-generated method stub
		return getString(R.string.title_8);
	}

	@Override
	protected void init() {
		// TODO Auto-generated method stub
		baseSetting = (StoreBaseSetting) getIntent().getSerializableExtra("data");
		initView();
		show();
	}

	private void show() {
		edt_store_name.setText(baseSetting.store_name);
		edt_tel.setText(baseSetting.tel);
		edt_qq.setText(getIntent().getStringExtra("qq"));
		edt_wangwang.setText(baseSetting.im_ww);
		edt_baoyou_jine.setText(baseSetting.amount_for_free_fee);
		edt_baoyou_shuliang.setText(baseSetting.acount_for_free_fee);
		edt_baoyou_content.setText(baseSetting.description);
	}

	private void initView() {
		edt_store_name = (EditText) findViewById(R.id.edt_store_name);
		edt_tel = (EditText) findViewById(R.id.edt_tel);
		edt_qq = (EditText) findViewById(R.id.edt_qq);
		edt_wangwang = (EditText) findViewById(R.id.edt_wangwang);
		edt_baoyou_jine = (EditText) findViewById(R.id.edt_baoyou_jine);
		edt_baoyou_shuliang = (EditText) findViewById(R.id.edt_baoyou_shuliang);

	}

	/**
	 * TODO ������֤,�ɸ�����Ҫ�����޸Ĳ���
	 */
	public void submit(View view) {
		// ��ʼ��֤��������
		String store_name = edt_store_name.getText().toString().trim();
		// if (TextUtils.isEmpty(name)) {
		// Toast.makeText(this, "name����Ϊ��", Toast.LENGTH_SHORT).show();
		// return;
		// }

		String tel = edt_tel.getText().toString().trim();
		// if (TextUtils.isEmpty(tel)) {
		// Toast.makeText(this, "tel����Ϊ��", Toast.LENGTH_SHORT).show();
		// return;
		// }

		String im_qq = edt_qq.getText().toString().trim();
		// if (TextUtils.isEmpty(qq)) {
		// Toast.makeText(this, "qq����Ϊ��", Toast.LENGTH_SHORT).show();
		// return;
		// }

		String im_ww = edt_wangwang.getText().toString().trim();
		// if (TextUtils.isEmpty(wangwang)) {
		// Toast.makeText(this, "wangwang����Ϊ��", Toast.LENGTH_SHORT).show();
		// return;
		// }

		String amount_for_free_fee = edt_baoyou_jine.getText().toString().trim();
		// if (TextUtils.isEmpty(jine)) {
		// Toast.makeText(this, "jine����Ϊ��", Toast.LENGTH_SHORT).show();
		// return;
		// }

		String acount_for_free_fee = edt_baoyou_shuliang.getText().toString().trim();
		// if (TextUtils.isEmpty(shuliang)) {
		// Toast.makeText(this, "shuliang����Ϊ��", Toast.LENGTH_SHORT).show();
		// return;
		// }
		String description = edt_baoyou_content.getText().toString().trim();

		Map<String, String> map = HttpUtil.getParams("app", "shopmember", "act", "mystore", "store_name", store_name,
				"tel", tel, "im_qq", im_qq, "im_ww", im_ww, "amount_for_free_fee", amount_for_free_fee,
				"acount_for_free_fee", acount_for_free_fee, "description", description);
		Http.getInstant().sendRequest(context, map, new HttpListener() {
			
			@Override
			public void onHttpSuccess(String result) {
				Toast.makeText(context, "保存成功", Toast.LENGTH_SHORT).show();
				setResult(RESULT_OK);
				finish();
			}
			
			@Override
			public void onHttpError(String error) {
				// TODO Auto-generated method stub
				
			}
		});
	}
}
